#include <stdio.h>
#include <device.h>
#include <uart.h>
#include <config.h>
#include <errno.h>

int getchar(void)
{
	struct device *dev;
	struct uart_device *uart_dev;

	dev = device_lookup_by_id(DEVICE_UART, -1);
	uart_dev = dev->priv;
	return uart_dev->getc(dev);
}

int putc(int c)
{
	struct device *dev;
	struct uart_device *uart_dev;

	dev = device_lookup_by_id(DEVICE_UART, -1);
	uart_dev = dev->priv;
	return uart_dev->putc(dev, c);
}

int puts(const char *s)
{
	struct device *dev;
	struct uart_device *uart_dev;
	int res;

	dev = device_lookup_by_id(DEVICE_UART, -1);
	uart_dev = dev->priv;

	while (*s) {
		res = uart_dev->putc(dev, *s);
		if (IS_ERR(res)) 
			return res;
		s++;
	}
	return 0;
}

/*
void puts_u8_hex(uint8_t dat) 
{
	uint32_t tmp;

	puts("0x");
	tmp = (dat >> 4) & 0xf;
	putc((tmp > 9)? ('A' + tmp - 10): ('0' + tmp));
	tmp = dat & 0xf;
	putc((tmp > 9)? ('A' + tmp - 10): ('0' + tmp));
}
*/

